---
title: "Monthly JMMI Partners Tracker"
output:
flexdashboard::flex_dashboard:
orientation: columns
source_code: embed
theme: journal
logo: C:/Users/REACH_AO_YEMEN\Documents/REACH Yemen/2. Cash & Markets/7. JMMI_partners_tracker/logo/Asset1.png
output: html_document
---
```{r setup, include=FALSE}
library(flexdashboard)
library(knitr)
library(kableExtra)
library(zoo)
library(plotly)
library(ggplot2)
library(dplyr)
## Load files <- only bit that needs to be updated
dt_gov <- read.csv("outputs/data_jmmi partners tracker_all_2020-04-22.csv", stringsAsFactors = F)
dt_gov$X <- NULL
dt_gov$Date <- as.yearmon(dt_gov$JMMI)
## Prepare dataset
table <- dt_gov %>%
dplyr::select(-c("district_ID", "governorate_ID", "governorate_name", "JMMI")) %>%
group_by(Date) %>%
summarise(Observations = sum(org_num), Districts = n_distinct(district_name), Partners = n_distinct(org))
## Managing tooltips in ggplotly
## https://stackoverflow.com/questions/36325154/how-to-choose-variable-to-display-in-tooltip-when-using-ggplotly
## Line plot showing changes in engaged partners per month
plot1 <- ggplot(table, aes(as.Date(Date), Partners)) +
geom_line(color="red", size = 1) +
geom_point(color="red", size = 2, fill = NA) +
scale_shape(solid = FALSE) +
scale_x_date(date_labels = "%b-%Y", date_breaks = "1 month") +
ylab("Number of NGOs") +
xlab("Assessed Months")
theme_light()
## Line plot showing changes in number of KIs assessed per month
plot2 <- ggplot(table, aes(as.Date(Date), Observations)) +
geom_line(color="red", size = 1) +
geom_point(color="red", size = 2, fill = NA) +
scale_shape(solid = FALSE) +
scale_x_date(date_labels = "%b-%Y", date_breaks = "1 month") +
ylab("Total Observations") +
xlab("Assessed Months")
theme_light()
## Line plot showing changes in number of district assessed per month
plot3 <- ggplot(table, aes(as.Date(Date), Districts)) +
geom_line(color="red", size = 1) +
geom_point(color="red", size = 2, fill = NA) +
scale_shape(solid = FALSE) +
scale_x_date(date_labels = "%b-%Y", date_breaks = "1 month") +
ylab("Number of Districts") +
xlab("Assessed Months")
theme_light()
```
All
=======================================================================
Column {data-width=350}
-----------------------------------------------------------------------
### **Assessments analytics by month of data collection**
```{r, results='asis'}
kable(table)%>%
kable_styling(bootstrap_options = c("striped", "hover", "condensed", "responsive"),fixed_thead = T, full_width = T)
```
Column {data-width=650}
-----------------------------------------------------------------------
### **Number of partners involved in data collection**
```{r}
ggplotly(plot1, tooltip = c("Partners"))
```
### **Number of KI assessed per month**
```{r}
ggplotly(plot2, tooltip = c("Observations"))
```
### **Number of district assessed per month**
```{r}
ggplotly(plot3, tooltip = c("Districts"))
```
North
=======================================================================
```{r, include=FALSE}
## Take the main table and filter it by north
north <- filter(dt_gov, geo == "North")
n_table <- north %>%
dplyr::select(-c("district_ID", "governorate_ID", "governorate_name", "JMMI")) %>%
group_by(Date) %>%
summarise(Observations = sum(org_num), Districts = n_distinct(district_name), Partners = n_distinct(org))
## Line plot showing changes in engaged partners by month
plot1n <- ggplot(n_table, aes(as.Date(Date), Partners)) +
geom_line(color="red", size = 1) +
geom_point(color="red", size = 2, fill = NA) +
scale_shape(solid = FALSE) +
scale_x_date(date_labels = "%b-%Y", date_breaks = "1 month") +
ylab("Number of NGOs") +
xlab("Assessed Months")
theme_light()
## Line plot showing changes in number of KIs assessed by month
plot2n <- ggplot(n_table, aes(as.Date(Date), Observations)) +
geom_line(color="red", size = 1) +
geom_point(color="red", size = 2, fill = NA) +
scale_shape(solid = FALSE) +
scale_x_date(date_labels = "%b-%Y", date_breaks = "1 month") +
ylab("Total Observations") +
xlab("Assessed Months")
theme_light()
## Line plot showing changes in number of district assessed by month
plot3n <- ggplot(n_table, aes(as.Date(Date), Districts)) +
geom_line(color="red", size = 1) +
geom_point(color="red", size = 2, fill = NA) +
scale_shape(solid = FALSE) +
scale_x_date(date_labels = "%b-%Y", date_breaks = "1 month") +
ylab("Number of Districts") +
xlab("Assessed Months")
theme_light()
```
Column {data-width=350}
-----------------------------------------------------------------------
### **Assessments analytics by month of data collection**
```{r, results='asis'}
kable(n_table)%>%
kable_styling(bootstrap_options = c("striped", "hover", "condensed", "responsive"),fixed_thead = T, full_width = T)
```
Column {data-width=650}
-----------------------------------------------------------------------
### **Number of partners involved in data collection**
```{r}
ggplotly(plot1n, tooltip = c("Partners"))
```
### **Number of KI assessed per month**
```{r}
ggplotly(plot2n, tooltip = c("Observations"))
```
### **Number of district assessed per month**
```{r}
ggplotly(plot3n, tooltip = c("Districts"))
```
South
=======================================================================
```{r, include=FALSE}
## Take the main table and filter it by south
south <- filter(dt_gov, geo == "South")
s_table <- south %>%
dplyr::select(-c("district_ID", "governorate_ID", "governorate_name", "JMMI")) %>%
group_by(Date) %>%
summarise(Observations = sum(org_num), Districts = n_distinct(district_name), Partners = n_distinct(org))
## Line plot showing changes in engaged partners by month
plot1s <- ggplot(s_table, aes(as.Date(Date), Partners)) +
geom_line(color="red", size = 1) +
geom_point(color="red", size = 2, fill = NA) +
scale_shape(solid = FALSE) +
scale_x_date(date_labels = "%b-%Y", date_breaks = "1 month") +
ylab("Number of NGOs") +
xlab("Assessed Months")
theme_light()
## Line plot showing changes in number of KIs assessed by month
plot2s <- ggplot(s_table, aes(as.Date(Date), Observations)) +
geom_line(color="red", size = 1) +
geom_point(color="red", size = 2, fill = NA) +
scale_shape(solid = FALSE) +
scale_x_date(date_labels = "%b-%Y", date_breaks = "1 month") +
ylab("Total Observations") +
xlab("Assessed Months")
theme_light()
## Line plot showing changes in number of district assessed by month
plot3s <- ggplot(s_table, aes(as.Date(Date), Districts)) +
geom_line(color="red", size = 1) +
geom_point(color="red", size = 2, fill = NA) +
scale_shape(solid = FALSE) +
scale_x_date(date_labels = "%b-%Y", date_breaks = "1 month") +
ylab("Number of Districts") +
xlab("Assessed Months")
theme_light()
```
Column {data-width=350}
-----------------------------------------------------------------------
### **Assessments analytics by month of data collection**
```{r, results='asis'}
kable(s_table)%>%
kable_styling(bootstrap_options = c("striped", "hover", "condensed", "responsive"),fixed_thead = T, full_width = T)
```
Column {data-width=650}
-----------------------------------------------------------------------
### **Number of partners involved in data collection**
```{r}
ggplotly(plot1s, tooltip = c("Partners"))
```
### **Number of KI assessed per month**
```{r}
ggplotly(plot2s, tooltip = c("Observations"))
```
### **Number of district assessed per month**
```{r}
ggplotly(plot3s, tooltip = c("Districts"))
```
Contested
=======================================================================
```{r, include=FALSE}
## Take the main table and filter it by contested
cnt <- filter(dt_gov, geo == "Contested")
cnt_table <- cnt %>%
dplyr::select(-c("district_ID", "governorate_ID", "governorate_name", "JMMI")) %>%
group_by(Date) %>%
summarise(Observations = sum(org_num), Districts = n_distinct(district_name), Partners = n_distinct(org))
## Line plot showing changes in engaged partners by month
plot1c <- ggplot(cnt_table, aes(as.Date(Date), Partners)) +
geom_line(color="red", size = 1) +
geom_point(color="red", size = 2, fill = NA) +
scale_shape(solid = FALSE) +
scale_x_date(date_labels = "%b-%Y", date_breaks = "1 month") +
ylab("Number of NGOs") +
xlab("Assessed Months")
theme_light()
## Line plot showing changes in number of KIs assessed by month
plot2c <- ggplot(cnt_table, aes(as.Date(Date), Observations)) +
geom_line(color="red", size = 1) +
geom_point(color="red", size = 2, fill = NA) +
scale_shape(solid = FALSE) +
scale_x_date(date_labels = "%b-%Y", date_breaks = "1 month") +
ylab("Total Observations") +
xlab("Assessed Months")
theme_light()
## Line plot showing changes in number of district assessed by month
plot3c <- ggplot(cnt_table, aes(as.Date(Date), Districts)) +
geom_line(color="red", size = 1) +
geom_point(color="red", size = 2, fill = NA) +
scale_shape(solid = FALSE) +
scale_x_date(date_labels = "%b-%Y", date_breaks = "1 month") +
ylab("Number of Districts") +
xlab("Assessed Months")
theme_light()
```
Column {data-width=350}
-----------------------------------------------------------------------
### **Assessments analytics by month of data collection**
```{r, results='asis'}
kable(cnt_table)%>%
kable_styling(bootstrap_options = c("striped", "hover", "condensed", "responsive"),fixed_thead = T, full_width = T)
```
Column {data-width=650}
-----------------------------------------------------------------------
### **Number of partners involved in data collection**
```{r}
ggplotly(plot1c, tooltip = c("Partners"))
```
### **Number of KI assessed per month**
```{r}
ggplotly(plot2c, tooltip = c("Observations"))
```
### **Number of district assessed per month**
```{r}
ggplotly(plot3c, tooltip = c("Districts"))
```